package com.atguigu.tingshu.account.mapper;

import com.atguigu.tingshu.model.account.UserAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;

@Mapper
public interface UserAccountMapper extends BaseMapper<UserAccount> {


    /**
     * 检查账户的可用金额
     * @param userId
     * @param amount
     * @return
     */
    public abstract UserAccount check(@Param(value = "userId") Long userId, @Param(value = "amount") BigDecimal amount);

    /**
     * 进行账户可用余额的锁定
     * @param userId
     * @param amount
     * @return
     */
    public abstract int lock(@Param(value = "userId") Long userId, @Param(value = "amount") BigDecimal amount);


    /**
     * 进行账户可用金额的扣减
     * @param userId
     * @param amount
     * @return
     */
    public abstract  int minusAccount(@Param(value = "userId") Long userId, @Param(value = "amount") BigDecimal amount);

    /**
     * 解锁账户锁定金额
     * @param userId
     * @param amount
     * @return
     */

    public abstract int unLock(Long userId, BigDecimal amount);
}
